package text;

public class Main {
	public static void main(String[] args) {
		Shape m[]=new Shape[3];
		m[0]=new rectangle(3,4);
		m[1]=new circle(3);
		m[2]=new yuanzhu(3,5);
		for(int i=0;i<m.length;i++) {
			show(m[i]);
		}

	}
	public static void show(Shape a) {
        if(a instanceof rectangle)
            System.out.println("矩形的面积：");
        else if(a instanceof circle)
            System.out.println("圆的面积：");
        else if(a instanceof yuanzhu)
            System.out.println("圆柱的体积为：");

        System.out.println(a.size());
    }
}
	interface Shape{
		abstract double size();
	}
 class rectangle implements Shape{
	 int x,y;
	 public rectangle(int x,int y) {
		 this.x=x;
		 this.y=y;
	 }
	public double size() {
		
		return x*y;
	}
	 
 }
 class circle implements Shape{
	 double r;
	 public circle(double r) {
		 this.r=r;
	 }
	 public double size() {
		 return r*r*Math.PI;
	 }
 }
class yuanzhu implements Shape{
	double V;
	double S;
	double r;
	double h;
	public  yuanzhu(double r,double h) {
		this.r=r;
		this.h=h;
		S=r*r*Math.PI;
		
	}
	public double size() {
		V=S*h;
		return V;
	}
}

